/**
* 模式 mixin
*/
export default {

	install(Vue){
		Vue.mixin({
			data(){
				return {
					isWechat: navigator && navigator.userAgent && navigator.userAgent.toLowerCase().indexOf('micromessenger') > -1
				}
			},
			computed:{
				userInfo(){
					return this.$store.state.userInfo;
				},
				networkState(){
					return this.$store.state.networkState;
				},
				showHeader(){
					return !this.isWechat;
				}
			},
			watch:{
				networkState(val, oldVal){
					console.log(val, oldVal);
				}
			},
			methods:{
				loadUserInfo(){
					this.$api.userService.info().then(res => {
						this.$store.commit('setUserInfo', res);
					});
				}
			}
		});
	}
}
